package com.lvyq.myplayer.model.index

import android.util.Log
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.lvyq.myplayer.net.api.indexDailyPlayApiService
import kotlinx.coroutines.launch

/**
 * 文件描述：IndexPlayLstModel 首页-甄选歌单
 * 作者：lvyq
 * 创建时间：2025-04-08
 * 修改时间：2025-04-08
 */
class IndexPickPlayLstModel : ViewModel() {
    private val _data =MutableLiveData<IndexPickPlayLstBean>()
    var data: LiveData<IndexPickPlayLstBean> = _data

    fun getPickPlayLst(){
        viewModelScope.launch {
            try {
                // 使用协程发起网络请求
                val response = indexDailyPlayApiService.getPickPlayLst()
                if (response.isSuccessful) {
                    _data.value = response.body()
                } else {
                    // 处理错误
                    Log.e("IndexPickPlayLstModel", "Error: ${response.code()}")
                }
            } catch (e: Exception) {
                // 处理异常
                Log.e("IndexPickPlayLstModel", "Exception: ${e.message}")
            }
        }
    }


}